﻿using System;
using System.Collections;

namespace ArrayListText
{
    //自定义比较器
    class MyCompare : IComparer
    {
        public int Compare(object x, object y)
        {
            string str1 = x.ToString();
            string str2 = y.ToString();
            return str1.CompareTo(str2);
        }
    }
    class Program
    {
        public int Age { get; set; }
        public int CompareTo(Program other)
        {
            if (this.Age > other.Age)
            {
                return 1;
            }else if (this.Age < other.Age)
            {
                return -1;
            }
            else
            {
                return 0;
            }
        }
    }
}
